package luogu;

import java.util.Objects;
import java.util.Scanner;

public class P1957 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] arr = new String[n];
        for (int i = 0; i < n; i++) {
            String first = sc.next();
            arr[i] = first;
            if ("abc".contains(first)){
                String a = sc.next();
                String b = sc.next();
                if (Objects.equals(first, "a")){
                    jia(a, b);
                }
                else if (Objects.equals(first, "b")){
                    jian(a, b);
                }
                else if (Objects.equals(first, "c")){
                    cheng(a, b);
                }
            }
            else {
                String a = first;
                String b = sc.next();
                int temp = i;
                while (!"abc".contains(arr[temp])){
                    temp--;
                }
                if (Objects.equals(arr[temp], "a")){
                    jia(a, b);
                }
                else if (Objects.equals(arr[temp], "b")){
                    jian(a, b);
                }
                else if (Objects.equals(arr[temp], "c")){
                    cheng(a, b);
                }
            }
        }
    }

    private static void jian(String a, String b) {
        int res = Integer.parseInt(a) - Integer.parseInt(b);
        System.out.println(a + "-" + b + "=" + res);
        System.out.println(a.length() + b.length() + 2 + String.valueOf(res).length());
    }

    private static void jia(String a, String b) {
        int res = Integer.parseInt(a) + Integer.parseInt(b);
        System.out.println(a + "+" + b + "=" + res);
        System.out.println(a.length() + b.length() + 2 + String.valueOf(res).length());
    }

    private static void cheng(String a, String b) {
        int res = Integer.parseInt(a) * Integer.parseInt(b);
        System.out.println(a + "*" + b + "=" + res);
        System.out.println(a.length() + b.length() + 2 + String.valueOf(res).length());
    }
}
